package com.tanhua.server.controller;

import com.tanhua.server.interceptor.UserHolder;
import com.tanhua.server.service.SoulTestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

@RestController
@RequestMapping("/testSoul")
public class SoulTestController {
    @Autowired
    private SoulTestService soulTestService;
    @GetMapping
    public ResponseEntity findSoulTestList(){
        return soulTestService.findSoulTestList();
    }
    @PostMapping
    public ResponseEntity submitQuestion(@RequestBody Map answers){
        List<Map> idList = (List) answers.get("answers");
        Long userId = UserHolder.getUserId();
        return soulTestService.submitQuestion(userId,idList);
    }
    @GetMapping("/report/{id}")
    public ResponseEntity findReport(@PathVariable("id")String reportId){
        return soulTestService.findReport(reportId);
    }
}
